package com.wanlian.router.ui.main;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.wanlian.router.R;

/**
 * Created by Hyu on 2018/10/8.
 * Email: fvaryu@163.com
 */
public class PointAdapter extends RecyclerView.Adapter<PointAdapter.H> {

    private int size;
    private int current;

    public void setSize(int size) {
        this.size = size;
        notifyDataSetChanged();
    }

    public void setCurrent(int current) {
        this.current = current;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public H onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new H(LayoutInflater.from(viewGroup.getContext())
                .inflate(R.layout.layout_point, viewGroup, false)
        );
    }

    @Override
    public void onBindViewHolder(@NonNull H h, int i) {

        h.itemView.setEnabled(current == i);
    }

    @Override
    public int getItemCount() {
        return size;
    }

    class H extends RecyclerView.ViewHolder {

        public H(@NonNull View itemView) {
            super(itemView);
        }
    }
}
